<template>
	<view class="containerbox">
		<uv-navbar title="21天抗遗忘" auto-back placeholder />
		<!-- <z-paging ref="paging" class="containerbox" v-model="list" @query="querylist"> -->
		<scroll-view scroll-y class="containerbox" @scrolltolower="scrolltolowerFn()">
			<dw_loading :status="loading" />
			<view class="px-30 containerbox pb-24" v-if="list.length">
				<view class="mt-30" v-for="(item,index) in list" :key="index">
					<view class="text-28 mb-30 color-3d mt-20" v-if="item.reviewDate">{{ item.reviewDate }}</view>
					<template  v-for="(childItem, idx) in item.list" :key="childItem.id">
						<view class="flex-center round-lg mb-25 p-25 bgF7">
							<view class="text-40 font-weight-600 color-3a">{{ childItem.startTime }}</view>
							<view class="flex-1 ml-25 color6">
								<view class="text-30"> <text class="text-30 mr-10" v-for="itm,idx in childItem.course" :key="idx">{{itm.name}}</text></view>				
								<view class="text-26 mt-10">{{ childItem.learn?.startTime }}</view>
							</view>
							<!-- <view @tap.stop="goOver(startTime, reviewDate, id)" class="text-white text-26 bgc-primary w-100 py-15 text-center round-10">复习</view> -->
						</view>
						
						<view class="flex mb-30 mt-15" style="justify-content: flex-end">
							<view
								v-if="childItem.isReview"
								@tap.stop="goReport(childItem.id, childItem.reviewLogId)" 
								class="text-primary border-primary w-140 py-15 text-center round-10 mr-10 text-26" 
							>
								学情报告
							</view>
							<view @tap.stop="goOver(childItem.startTime, childItem.reviewDate, childItem.id)" class="text-white  bgc-primary w-100 py-15 text-center round-10 text-26">复习</view>
						</view>
					</template>
				</view>
				<view class="pb-24">
					<uv-load-more :status="status" font-size="28rpx" />
				</view>
			</view>
			<view v-if="!list.length&&!loading" class="flex-1 flex justify-center items-center containerbox">
				<dw_default label="暂无抗遗忘" src="https://dwzx.dingwei.cn/student/static/home/empty.svg"></dw_default>
			</view>
		</scroll-view>
		<!-- </z-paging> -->
	</view>
</template>

<script setup>
	
	import { onShow } from '@dcloudio/uni-app';
	import { imgPath } from '@/common/config.js'
	import { ref , reactive } from 'vue'
	import { remberList } from '@/common/apis/other'
	
	let paging = ref(null)
	let list = ref([])
	let loading = ref(true)
	
	
	const status= ref('loadmore')
	const pages = reactive({
		page:1,
		pageSize:10
	})
	const isOver = ref(true)
	/** 获取列表 */
	async function querylist(page, pageSize) {
		const params = { ...pages, simplePage: 1 };
		status.value = 'loading'
		const result = await remberList(params);
		let arr = []
		result.forEach(item=>{
			arr = [...arr,...item.list]
		})
		if(arr.length>=10) {
			pages.page ++ 
		}else{
			status.value = 'nomore'
			isOver.value = false
		}
		list.value = list.value.concat(result)
		// paging.value.complete(result);
		uni.$fui.sleep(() => loading.value = false, 800);
	};
	onShow(async () => {
		loading.value = true;
		list.value = [];
		pages.page = 1;
		await querylist();
	});
	function scrolltolowerFn(){
		console.log('底部')
		if(isOver.value) querylist()
	}
	
	// async function querylist(page, pageSize) {//获取列表
	// 	let params = { page, pageSize, simplePage: 1 }
	// 	let result = await remberList(params)
	// 	paging.value.complete(result)
	// 	uni.$fui.sleep(() => loading.value = false)
	// }

	let goOver = (startTime, reviewDate, id) =>{
		let nowTime = new Date().getTime()
		// let startTime1 = new Date(reviewDate).getTime()
		// if (startTime1 > nowTime) {
		// 	uni.$fui.toast('还未到复习时间')
		// 	return false
		// }
		uni.$fui.href('/pages/study/goOver', { id , type: 1 })
	} 
	
	/** 去学情报告 */
	const goReport = (id,reviewLogId) => {
		uni.$fui.href('/pages/study/go-over-report', { id: reviewLogId })
	};
	
</script>

<style>page{background: #FFFFFF}</style>
<style scoped lang="scss">
	.color-3d{color: #3D4B55}
	.color-3a{color: #3A3F5E}
	.color6{color: #626780}
	.bgF7{background: #F7F8FA}
</style>